package DailySheet.Activity;

import hepengfei.SQL.XMLConfig;
import DailySheet.Activity.ProfileChoice.newListener1;
import android.R.integer;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import DailySheet.CourseManage.Macro_variable;

public class SetTimeTableAct extends Activity{

	EditText amEditText1;
	EditText amEditText2;
	EditText amEditText3;
	EditText amEditText4;

	EditText pmEditText1;
	EditText pmEditText2;
	EditText pmEditText3;
	EditText pmEditText4;
	
	EditText ntEditText1;
	EditText ntEditText2;
	EditText ntEditText3;
	EditText ntEditText4;
	
	Button summerButton;
	Button winterButton;
	Button defaultButton;
	Button okButton;
	
	XMLConfig config;
	int season;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setdate);
		amEditText1 = (EditText) findViewById(R.id.set_am_starttime);
		amEditText2 = (EditText) findViewById(R.id.set_am_lasttime);
		amEditText3 = (EditText) findViewById(R.id.set_am_breaktime);
		amEditText4 = (EditText) findViewById(R.id.set_am_starttime_minute);
		pmEditText1 = (EditText) findViewById(R.id.set_pm_starttime);
		pmEditText2 = (EditText) findViewById(R.id.set_pm_lasttime);
		pmEditText3 = (EditText) findViewById(R.id.set_pm_breaktime);
		pmEditText4 = (EditText) findViewById(R.id.set_pm_starttime_minute);
		ntEditText1 = (EditText) findViewById(R.id.set_nt_starttime);
		ntEditText2 = (EditText) findViewById(R.id.set_nt_lasttime);
		ntEditText3 = (EditText) findViewById(R.id.set_nt_breaktime);
		ntEditText4 = (EditText) findViewById(R.id.set_nt_starttime_minute);
		
		summerButton = (Button) findViewById(R.id.set_summer_button);
		winterButton = (Button) findViewById(R.id.set_winter_button);
		defaultButton = (Button) findViewById(R.id.set_default_button);
		okButton = (Button) findViewById(R.id.set_ok_button);
				
		config = new XMLConfig(SetTimeTableAct.this);
//		winterButton.setClickable(false);
		
		season = Macro_variable.Summer;
		
		summerButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				summerButton.setEnabled(false);
				winterButton.setEnabled(true);
				
				amEditText1.setText("8");
				amEditText2.setText("45");
				amEditText3.setText("30");
				amEditText4.setText("00");
				
				pmEditText1.setText("14");
				pmEditText2.setText("45");
				pmEditText3.setText("15");
				pmEditText4.setText("30");
				
				ntEditText1.setText("19");
				ntEditText2.setText("45");
				ntEditText3.setText("10");
				ntEditText4.setText("30");
				
				season = Macro_variable.Summer;
			}
		});
		
		winterButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				summerButton.setEnabled(true);
				winterButton.setEnabled(false);
				
				amEditText1.setText("8");
				amEditText2.setText("45");
				amEditText3.setText("30");
				amEditText4.setText("00");
				
				pmEditText1.setText("14");
				pmEditText2.setText("45");
				pmEditText3.setText("15");
				pmEditText4.setText("00");
				
				ntEditText1.setText("19");
				ntEditText2.setText("45");
				ntEditText3.setText("10");
				ntEditText4.setText("00");
				
				season = Macro_variable.Summer;
			}
		});
		
		defaultButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				amEditText1.setText("8");
				amEditText2.setText("45");
				amEditText3.setText("30");
				amEditText4.setText("00");
				
				pmEditText1.setText("14");
				pmEditText2.setText("45");
				pmEditText3.setText("15");
				pmEditText4.setText("30");
				
				ntEditText1.setText("19");
				ntEditText2.setText("45");
				ntEditText3.setText("10");
				ntEditText4.setText("00");
			}
		});
		
		okButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				config.ConfigSeason(season);
				config.ConfigLastTime(Integer.parseInt(amEditText2.getText().toString()));
				config.ConfigStartTimeofNoon(Integer.parseInt(amEditText1.getText().toString())
						, Integer.parseInt(amEditText4.getText().toString()));
				
				config.ConfigStartTimeofAfnoon(Integer.parseInt(pmEditText1.getText().toString())
						, Integer.parseInt(pmEditText4.getText().toString()));
				
				config.ConfigNightLast(Integer.parseInt(amEditText2.getText().toString()));
				config.ConfigNightStart(Integer.parseInt(ntEditText1.getText().toString())
						, Integer.parseInt(ntEditText4.getText().toString()));
				
//				config.ConfigStartTimeofNoon(hour, minute)
//				config.ConfigStartTimeofNoon(hour, minute)
				
			}
		});

	}
	
}
